package com.neusoft.data.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.neusoft.data.domain.SerServiceEvaluation;
import com.neusoft.data.service.ISerServiceEvaluationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务评价Controller
 * 
 * @author slh
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/courseSelect/evaluation")
public class SerServiceEvaluationController extends BaseController
{
    @Autowired
    private ISerServiceEvaluationService serServiceEvaluationService;

    /**
     * 查询服务评价列表
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:evaluation:list')")
    @GetMapping("/list")
    public TableDataInfo list(SerServiceEvaluation serServiceEvaluation)
    {
        startPage();
        List<SerServiceEvaluation> list = serServiceEvaluationService.selectSerServiceEvaluationList(serServiceEvaluation);
        return getDataTable(list);
    }

    /**
     * 导出服务评价列表
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:evaluation:export')")
    @Log(title = "服务评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerServiceEvaluation serServiceEvaluation)
    {
        List<SerServiceEvaluation> list = serServiceEvaluationService.selectSerServiceEvaluationList(serServiceEvaluation);
        ExcelUtil<SerServiceEvaluation> util = new ExcelUtil<SerServiceEvaluation>(SerServiceEvaluation.class);
        util.exportExcel(response, list, "服务评价数据");
    }

    /**
     * 获取服务评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:evaluation:query')")
    @GetMapping(value = "/{serviceEvalId}")
    public AjaxResult getInfo(@PathVariable("serviceEvalId") Long serviceEvalId)
    {
        return success(serServiceEvaluationService.selectSerServiceEvaluationByServiceEvalId(serviceEvalId));
    }

    /**
     * 新增服务评价
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:evaluation:add')")
    @Log(title = "服务评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SerServiceEvaluation serServiceEvaluation)
    {
        return toAjax(serServiceEvaluationService.insertSerServiceEvaluation(serServiceEvaluation));
    }

    /**
     * 修改服务评价
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:evaluation:edit')")
    @Log(title = "服务评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SerServiceEvaluation serServiceEvaluation)
    {
        return toAjax(serServiceEvaluationService.updateSerServiceEvaluation(serServiceEvaluation));
    }

    /**
     * 删除服务评价
     */
    @PreAuthorize("@ss.hasPermi('courseSelect:evaluation:remove')")
    @Log(title = "服务评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{serviceEvalIds}")
    public AjaxResult remove(@PathVariable Long[] serviceEvalIds)
    {
        return toAjax(serServiceEvaluationService.deleteSerServiceEvaluationByServiceEvalIds(serviceEvalIds));
    }
}
